package com.nbsaas.boot.front.site;

import com.nbsaas.boot.rest.annotations.AddOperator;
import com.nbsaas.boot.rest.annotations.CreateData;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.site.api.apis.AdviseApi;
import com.nbsaas.boot.site.api.domain.request.AdviseRequest;
import com.nbsaas.boot.site.api.domain.response.AdviseResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 控制器
 */
@RestController
@RequestMapping("/front/advise")
public class AdviseAction {


    @Resource
    private AdviseApi adviseApi;


    /**
     * 添加数据
     *
     * @param request
     * @return
     */
    @PostMapping("/create")
    public ResponseObject<AdviseResponse> create(@RequestBody @Validated(AddOperator.class) AdviseRequest request) {
        request.setAddDate(new Date());
        request.setLastDate(new Date());
        return adviseApi.create(request);
    }


}